package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.entity.NursingPlan;
import com.zzyl.entity.NursingProject;
import com.zzyl.entity.NursingProjectPlan;
import com.zzyl.vo.NursingPlanVo;
import com.zzyl.vo.NursingProjectPlanVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.ArrayList;
import java.util.List;


@Mapper
public interface NursingPlanMapper {

    /**
     * 分页查询护理计划
     *
     * @param name     护理计划名称
     * @param status   护理计划状态
     * @return
     */
    Page<NursingPlanVo> getByPage(String name, Integer status);

    /**
     * 添加护理计划
     * @param nursingPlan 护理计划内容
     * @return
     */
    void addPlan(NursingPlan nursingPlan);

    /**
     * 添加护理计划项目
     * @param nursingProjectPlan
     */
    void addProjectPlan(NursingProjectPlan nursingProjectPlan);

    /**
     * 删除护理计划
     * @param id 要删除的护理计划id
     * @return
     */
    @Delete("delete from nursing_plan where id =#{id}")
    void delete(Long id);

    /**
     * 删除护理计划项目
     * @param id 护理计划的id
     * @return
     */
    @Delete("delete from nursing_project_plan where plan_id=#{id}")
    void deleteProjectPlan(Long id);

    /**
     * 根据id查询护理计划
     * @param id 护理计划id
     * @return 护理计划详情
     */

    NursingPlan getById(Long id);

    /**
     * 根据护理计划id查询护理计划项目
     * @param id 护理计划id
     * @return
     */
    @Select("select * from nursing_project_plan where plan_id = #{id}")
    List<NursingProjectPlanVo> getProjectPlan(Long id);
    /**
     * 编辑护理计划
     * @param nursingPlan 护理计划信息
     * @return
     */
    void updatePlan(NursingPlan nursingPlan);

    /**
     * 根据护理项目id查询护理项目
     * @param projectId 护理项目id
     * @return
     */
    @Select("select * from nursing_project where id = #{projectId}")
    NursingProject getProjectById(Long projectId);

    /**
     * 改变护理计划状态
     * @param id 护理计划id
     * @param status 状态
     * @return
     */
    @Update("update nursing_plan set status = #{status}  where id = #{id}")
    void updateStatus(Long id, Integer status);

    /**
     * 查询所有护理计划
     * @return
     */
    @Select("select * from nursing_plan")
    List<NursingPlanVo> getAllPlan();

    @Select("select id from nursing_project_plan where id = #{id};")
    ArrayList<Integer> addProjectPlan1(NursingProjectPlanVo projectPlanVo);

    @Select("select id from nursing_plan where  plan_name = #{planName};")
    Long getIdByPlanName(String planName);
}
